#include "Server.h"
#include <iostream>
#include <string>

int main()
{
	Server server(4455); // 创建一个监听 8080 端口的服务器

	// 启动服务器
	if (!server.start())
	{
		return -1;
	}

	// 等待客户端连接
	if (!server.acceptClient())
	{
		return -1;
	}

	string message_to_send;
	string message_received;

	while (true)
	{
		cout << "send: ";
		getline(cin, message_to_send);
		// 向客户端发送数据
		server << message_to_send;

		// 从客户端接收数据
		server >> message_received;
		cout << "receive: " << message_received << endl;
	}

	// 关闭服务器
	server.closeServer();

	return 0;
}